home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Viewers / aa_m68k_Intel_Only / ToyViewer1.2 / Source / ToyWinGIF.m < prev    next >
Encoding:
Text File  |  1995-11-12  |  1.0 KB  |  43 lines

  1. #import "ToyWinGIF.h"
  2. #import "gif.h"
  3.  
  4. @implementation ToyWinGIF
  5.  
  6. - (int)drawToyWin:(const char *)fileName Type:(int)type Num:(int)num
  7. {
  8.     FILE *fp;
  9.     gifHeader *gh = NULL;
  10.     commonInfo *cinf = NULL;
  11.     int bits = 8, err = 0;
  12.     unsigned char *map[5];
  13.  
  14.     if ((fp = fopen(fileName, "r")) == NULL)
  15.         return Err_OPEN;
  16.     if ((gh = loadGifHeader(fp, &err)) == NULL) {
  17.         (void)fclose(fp);
  18.         return err;
  19.     }
  20.  
  21.     [self initLocateWindow:fileName
  22.         Width:gh->width Height:gh->height Num:num];
  23.  
  24. /* Bitmap data of planes in 'map[]' is one block of memory area.
  25.    map[0] is beginning of the area, and map[1] = map[0] + (size of plane),
  26.    and so on. But, if the image is monochrome, map[1] is NULL.
  27.    The area of map[0] and (commonInfo *)cinf are kept in an object of
  28.    ToyView, and freed by it.
  29. */
  30.     err = gifGetImage(fp, gh, &bits, map);
  31.     cinf = gifInfo(gh, bits, (map[1] == NULL));
  32.     freeGifHeader(gh);
  33.     (void)fclose(fp);
  34.     if (err) /* •ä„ö⁄˛⁄ë */
  35.         errAlert(fileName, err);
  36.     if ([self drawView:map info: cinf] == nil)
  37.         return -1;
  38.  
  39.     return 0;
  40. }
  41.  
  42. @end
  43.